﻿using System.Text;
using System.Security.Cryptography;
using System;

namespace LuckyLoot.Domain.ValueObjects
{
    public class Password
    {
        public string Value { get; set; }
        
        public bool Match(Password pwd)
        {
            string current = this;
            string candidate = pwd;

            return string.Equals(current, candidate, StringComparison.Ordinal);
        }

        public override string ToString()
        {
            return (string)this;
        }

        #region [ Operators ]

        public static implicit operator string(Password pwd)
        {
            if (pwd == null)
                return string.Empty;

            return pwd.Value;
        }

        /// <summary>
        /// Transforma implicitamente uma string em uma senha.
        /// </summary>
        /// <param name="value">Senha</param>
        /// <returns>Um objeto de senha contendo a senha passada criptografada.</returns>
        public static implicit operator Password(string value)
        {
            Password pwd = new Password();
            pwd.Value = value;

            return pwd;
        }

        #endregion
    }
}
